﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Netcached.Tests
{
    [TestClass]
    public class TestReplace : BaseTestClass
    {
        [TestMethod]
        public void TestReplaceValue()
        {
            string key = "TestReplace.TestReplaceValue";
            string origValue = "data";
            string replacedValue = "data1";

            Client.Set(key, origValue);
            Client.Replace(key, replacedValue);

            var fetchedValue = Client.Get(key);
            Assert.AreEqual(replacedValue, fetchedValue);
        }

        [TestMethod]
        public void TestReplaceNonexistentValue()
        {
            string key = "TestReplace.TestReplaceNonexistentValue";
            string value = "data";

            var result = Client.Replace(key, value);

            var fetchedValue = Client.Get<string>(key);

            Assert.IsFalse(result);
            Assert.IsNull(fetchedValue);
        }
    }
}
